package com.example.demo.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhanpengguo
 * @date 2019-07-03 13:47
 */
@Controller
@RequestMapping("/view")
public class ViewController {

    @GetMapping("/login")
    public String defaultLogin(){
        return "/login";
    }

    @GetMapping("/index")
    public String index(){
        return "/index";
    }

    @GetMapping("/error")
    public String error(){
        return "/error";
    }

    /*@PostMapping("/login")
    @ResponseBody
    public String login(@RequestParam("username") String username, @RequestParam("password") String password){

        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, password);
        subject.login(usernamePasswordToken);
        if (subject.isAuthenticated()){
            return "登陆成功";
        }else {
            usernamePasswordToken.clear();
            return "登陆失败";
        }
    }*/
}
